<?php
/**
 * Course Class Model
 *
 * Copyright 2012
 * @date 21-April-2012
 * @author 
 * @version 0.0.1
 **/
class ResponsesQuestionsOption extends AppModel {
/**
 * Name
 *
 * @var string
 */
    public $name = "ResponsesQuestionsOption"; 
    public $useTable = "responses_questions_options";
    /*public $belongsTo = array(
        'Response'=>array(
            'className'=>'Response',
            'foreignKey'=>'response_id'
        ),
        'Question'=>array(
            'className'=>'Question',
            'foreignKey'=>'question_id'
        ),
        'Option'=>array(
            
            'foreignKey'=>'option_id'
        )
    );*/
    public static function count_option_in_question($question_id,$option_id){
        $res = ClassRegistry::init("ResponsesQuestionsOption");
        return $res->find("count", array('conditions'=>array('question_id'=>$question_id,'option_id'=>$option_id)));
    }
    public static function get_option($response_id,$question_id){
        $res = ClassRegistry::init("ResponsesQuestionsOption");
        $res->bindModel(array('belongsTo'=>array('Option'=>array('className'=>'Option','foreignKey'=>'option_id'))));
        
        $option = $res->find("all",array('conditions'=>array('question_id'=>$question_id,'response_id'=>$response_id)));
        
        //pr($option);die;
        
        return $option;
    }
}